<?php
/**
 * XmuSlh, web platform of Student Association Federation of Xiamen University
 * 
 * Rewritting one or some pages of StatusNet. 
 * To get the original version, please visit <http://status.net/>.
 * 
 * StatusNet, the distributed open-source microblogging tool
 * 
 * LICENCE: This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

/**
 * Editprofileuser action form.
 * 编辑社联会用户的表格.
 * 
 * @author		ytukie <ytukie@gmail.com>
 * @version		0.2
 * 
 * 0.2)  Change the 'username' and 'realname' into 'readonly',
 * 		 while 'realname' is also a Primary Key, then it could not be changed.
 */

// XmuSlh only.
if ( !defined('XMUSLH')) { exit(1); }

// Requirements.
require_once INSTALLDIR . '/lib/slh_util.php';
require_once INSTALLDIR . '/lib/slh_form.php';

class EditprofileuserForm extends Form
{
	function prepareData()
	{
		$this->out->hidden('user_id', $this->getField('guser_id'));
	}
	
	/**
	 * ID of the from
	 */
	function id()
	{
		return 'id_form_editprofileuser';
	}
	
	/**
	 * Class of the form.
	 */
	/*
	function formClass()
	{
		// return 'class_settingsform';
	}
	*/
	
	/**
	 * Action of the form
	 * 
	 * Return the string URL of the action.
	 */
	function action()
	{
		return slh_action2url('editprofileuser', array('guser_id' => $this->getField('guser_id')));
	}
	
	/**
	 * Name of the form
	 */
	function formLegend()
	{
		$this->out->element('legend', null, 'edit profile');
	}
	
	/**
	 * Token of the form.
	 */
	function formToken()
	{
		$this->out->hidden('formtoken', 'editprofile');
	}
	
	/**
	 * Data elements.
	 */
	function formData()
	{
		$this->out->elementStart('dl', array('class' => 'cls_dl_form'));
		
		$this->out->element('dt', null, '账户信息');
		$this->out->elementStart('dd');
		$this->out->elementStart('ul');
			$this->out->elementStart('li');
			$this->out->readonly('username',
								 '用户名',
								 $this->getField('username'),
								 '[只读]登陆用的用户名呃.');
			$this->out->elementEnd('li');
			
			$this->out->elementStart('li');
			$this->out->element('a', array('href' => slh_action2url('deletepassword',
								  	   							  	array('guser_id' => $this->getField('guser_id'))),
										   'title'=> '删除原来的密码.'),
								'重置密码');
			$this->out->inputtips('重置这个密码就是说把它设置为用户名吼.');
			$this->out->elementEnd('li');
		$this->out->elementEnd('ul');
		$this->out->elementEnd('dd');
		
		$this->out->element('dt', null, '社联会用户信息');
		$this->out->elementStart('dd');
		$this->out->elementStart('ul');
			$this->out->elementStart('li');
			$this->out->readonly('realname',
							     '真实姓名',
							     $this->getField('realname'),
							     '[只读]真实的个人称呼,看来只能改后面的了.');
			$this->out->elementEnd('li');
			
			$this->out->elementStart('li');
			$this->out->input('pinyin',
						 	  '姓名的拼音', 
						  	  $this->getField('pinyin'),
						 	  '[选填]用于简化搜索.');
			$this->out->elementEnd('li');
			
			$this->out->elementStart('li');
			$this->out->input('department',
							  '所属部门', 
							  $this->getField('department'),
							  '所属社联会的部门,不能为空哦.');
			$this->out->elementEnd('li');
		$this->out->elementEnd('ul');
		$this->out->elementEnd('dd');
		
		$this->out->elementEnd('dl');
	}
	
	/**
	 * Action elements.
	 */
	function formActions()
	{
		$this->out->elementStart('div', 'formaction');
		$this->out->submit('submit',
						   '修改',
						   'submit',
						   'edit',
						   '修改当前的用户信息.');
		$this->out->elementEnd('div');
	}
}